<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>http 请求示例</title>
    <script src="js/jquery-3.5.0.js"></script>
    <script src="js/http.js"></script>
</head>
<body>

<button onclick="clickGetWithParams()">get 有参</button>
<button onclick="clickPostWithParams()">post 有参普通</button>
<button onclick="clickPostWithJson()">post 有参json</button>

</body>
</html>
<script>


    function clickGetWithParams() {
        //发起http请求
        // let url = "/user/infoWithId";
        let url = "/account/login";
        let params = {
            password: "123",
            userName: "jerry"
        };
        httpGetWithParams(url, params, function (resp) {

        })
    }

    function clickPostWithParams() {
        //发起http请求
        // let url = "/user/login";
        let url = "/account/login";
        let params = {
            userName: "mkr",
            password: "123456"
        };
        httpPostWithParams(url, params, function (resp) {
            console.log(resp);
        })
    }

    function clickPostWithJson() {
        //发起http请求
        let url = "/account/loginWithJson";
        let params = {
            password: "123456789",
            userName: "yxj"
        };
        let json = JSON.stringify(params);
        httpPostWithJson(url, json, function (resp) {
            console.log(resp)
        })
    }

</script>